import { useAxios } from '@/hooks/web/useAxios'
import type { TableData } from './types'
const request = useAxios()

import { useCache } from '@/hooks/web/useCache'
const { wsCache } = useCache()

// 商品列表
export const adminCsGoodsListApi = (data: any) => {
  return request.post({
    url: 'index.php/api/common',
    headers: { token: wsCache.get('token') },
    data: {
      code: 'adminCsGoodsList',
      data: data
    }
  })
}

// 查看
export const adminCsGoodsSeeApi = (data: any) => {
  return request.post({
    url: 'index.php/api/common',
    headers: { token: wsCache.get('token') },
    data: {
      code: 'adminCsGoodsSee',
      data: data
    }
  })
}

// 商品修改
export const adminCsGoodsEditApi = (data: TableData) => {
  return request.post({
    url: 'index.php/api/common',
    headers: { token: wsCache.get('token') },
    data: {
      code: 'adminCsGoodsEdit',
      data: data
    }
  })
}

// 商品新增
export const adminCsGoodsAddApi = (data: TableData) => {
  return request.post({
    url: 'index.php/api/common',
    headers: { token: wsCache.get('token') },
    data: {
      code: 'adminCsGoodsAdd',
      data: data
    }
  })
}

// 商品删除
export const adminCsGoodsDelApi = (data: TableData) => {
  return request.post({
    url: 'index.php/api/common',
    headers: { token: wsCache.get('token') },
    data: {
      code: 'adminCsGoodsDel',
      data: data
    }
  })
}

// 商品批量删除
export const adminCsGoodsBatchDelApi = (data: { ids: string }) => {
  return request.post({
    url: 'index.php/api/common',
    headers: { token: wsCache.get('token') },
    data: {
      code: 'adminCsGoodsBatchDel',
      data: data
    }
  })
}
